package com.zzyl.generator;

import com.zzyl.common.constant.Constants;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

public class VelocityDemoTest {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();
        properties.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        properties.setProperty(Velocity.INPUT_ENCODING, Constants.UTF8);
        Velocity.init(properties);

        VelocityContext context = new VelocityContext();
        context.put("message","生猴子");
        Template template = Velocity.getTemplate("vms/index.html.vm", "UTF-8");
        FileWriter fileWriter = new FileWriter("E:\\develop\\tmp\\index.html");
        template.merge(context,fileWriter);
        fileWriter.close();

    }
}
